package com.example.framework;

import org.hibernate.Session;
import org.hibernate.Transaction;

public class HibernateHelper extends BaseHelper {

	public HibernateHelper(HelperManager manager) {
	  super(manager);
	}

	public int deleteUser(User user) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Transaction trans = session.beginTransaction();

        String deleteQuery = "delete User u where u.email = :email";
		try {
            return session.createQuery(deleteQuery).setString("email", user.email).executeUpdate();
		} finally {
          trans.commit();
		}
	}

}
